import {defHttp} from '/@/utils/http/axios';
import {Modal} from 'ant-design-vue';

enum Api {
  savePermanent = '/infra-service/mpMaterial/savePermanentMaterial',
  page = '/infra-service/mpMaterial/pageMpMaterial',
  edit = '/infra-service/mpMaterial/updateMpMaterial',
  delete = '/infra-service/mpMaterial/deleteMpMaterial',

  pageNews = '/infra-service/mpDraft/pageMpMaterial',
}

/**
 * 列表
 * @param params
 */
export const pageMpMaterial = (params) => defHttp.get({url: Api.page, params});

/**
 * 列表
 * @param params
 */
export const pageMpNewsArticles = (params) => defHttp.get({url: Api.page, params});

/**
 * 删除
 */
export const deleteMpMaterial = (params, handleSuccess) => {
  return defHttp.delete({url: Api.delete, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
// /**
//  * 批量删除
//  * @param params
//  */
// export const batchDeleteMpAutoReply = (params, handleSuccess) => {
//   Modal.confirm({
//     title: '确认删除',
//     content: '是否删除选中数据',
//     okText: '确认',
//     cancelText: '取消',
//     onOk: () => {
//       return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
//         handleSuccess();
//       });
//     }
//   });
// }

/**
 * 保存永久素材
 * @param params
 */
export const savePermanentMaterial = (params) => {
  return defHttp.post({url: Api.savePermanent, params});
}


// /**
//  * 保存或者更新
//  * @param params
//  */
// export const saveOrUpdateMpAutoReply = (params, isUpdate) => {
//   let url = isUpdate ? Api.edit : Api.save;
//   return defHttp.post({url: url, params});
// }



